import socket

if __name__ == '__main__':
    # 1.创建一个套接字
    tcp_socket = socket.socket()

    # 2.建立连接
    address = ("192.168.199.128", 8080)
    tcp_socket.connect(address)

    # 3.和服务器通信
    while True:
        data = input("请输入数据：")
        if data == "退出":
            break
        else:
            tcp_socket.send(data.encode())

    # 4.接收数据
    result = tcp_socket.recv(1024)

    if result:
        print(f"女神回复了你：{result.decode()}")
    else:
        print("女神下线了，奉劝你一句：舔狗不得house")

    # 5.关闭套接字
    tcp_socket.close()
